<template>
  <div class="userinfo">
    <el-card class="userinfo-card">
      <template #header>
        <div class="card-header">
          <span>用户信息</span>
          <el-button class="button" text @click="logoutHandle">退出登录</el-button>
        </div>
      </template>
      <el-form class="userinfo-box" label-width="auto" size="large">
        <el-form-item label="用户名:"> {{ username }} </el-form-item>
        <el-form-item label="其他信息:"> {{ other }} </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: "testuser",
      other: "你好，用户",
    }
  },
  computed: {
    
  },
  methods: {
    logoutHandle() {
      this.$cookies.remove("vue-session")
      this.$router.push("/")
    }
  },
  mounted() {
    // 获取用户名
    let cookie = this.$cookies.get("vue-session")
    this.username = cookie.split(".")[1]
    console.log(this.username)
  }
}
</script>

<style scoped>
.userinfo {
  display: flex;
  height: 90vh;
  /* align-items: center; */
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
  
.userinfo-card {
  width: 480px;
  margin: auto;
  /* margin-top: 30vh; */
}
</style>